package com.roadjava.rbac.bean.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import lombok.Data;

/**
 * 权限表
 * @TableName authority
 */
@TableName(value ="authority")
@Data
public class AuthorityDO implements Serializable {
    /**
     * 主键
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 0:路由组件,1:按钮
     */
    private Integer type;

    /**
     * 0:否,1:是,为按钮时肯定是0
     */
    private Integer showInMenu;

    /**
     * 权限名称,可用于标题和菜单名称
     */
    private String authorityName;

    /**
     * 前端路由路径,为按钮时没有
     */
    private String path;

    /**
     * 关联的后端请求,多个通过,分隔
     */
    private String relateBackUris;

    /**
     * 前端组件相对@/views/所在的目录,如dept/DeptManage
     */
    private String componentPath;

    /**
     * 排序,越小排序越靠前
     */
    private Integer orderNo;

    /**
     * 菜单对应的图标名称
     */
    private String icon;

    /**
     * 父级id,-1:没有父级
     */
    private Long parentId;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        AuthorityDO other = (AuthorityDO) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
            && (this.getShowInMenu() == null ? other.getShowInMenu() == null : this.getShowInMenu().equals(other.getShowInMenu()))
            && (this.getAuthorityName() == null ? other.getAuthorityName() == null : this.getAuthorityName().equals(other.getAuthorityName()))
            && (this.getPath() == null ? other.getPath() == null : this.getPath().equals(other.getPath()))
            && (this.getRelateBackUris() == null ? other.getRelateBackUris() == null : this.getRelateBackUris().equals(other.getRelateBackUris()))
            && (this.getComponentPath() == null ? other.getComponentPath() == null : this.getComponentPath().equals(other.getComponentPath()))
            && (this.getOrderNo() == null ? other.getOrderNo() == null : this.getOrderNo().equals(other.getOrderNo()))
            && (this.getIcon() == null ? other.getIcon() == null : this.getIcon().equals(other.getIcon()))
            && (this.getParentId() == null ? other.getParentId() == null : this.getParentId().equals(other.getParentId()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
        result = prime * result + ((getShowInMenu() == null) ? 0 : getShowInMenu().hashCode());
        result = prime * result + ((getAuthorityName() == null) ? 0 : getAuthorityName().hashCode());
        result = prime * result + ((getPath() == null) ? 0 : getPath().hashCode());
        result = prime * result + ((getRelateBackUris() == null) ? 0 : getRelateBackUris().hashCode());
        result = prime * result + ((getComponentPath() == null) ? 0 : getComponentPath().hashCode());
        result = prime * result + ((getOrderNo() == null) ? 0 : getOrderNo().hashCode());
        result = prime * result + ((getIcon() == null) ? 0 : getIcon().hashCode());
        result = prime * result + ((getParentId() == null) ? 0 : getParentId().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", type=").append(type);
        sb.append(", showInMenu=").append(showInMenu);
        sb.append(", authorityName=").append(authorityName);
        sb.append(", path=").append(path);
        sb.append(", relateBackUris=").append(relateBackUris);
        sb.append(", componentPath=").append(componentPath);
        sb.append(", orderNo=").append(orderNo);
        sb.append(", icon=").append(icon);
        sb.append(", parentId=").append(parentId);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}